package com.suypower.carManage.action;

import com.jarp.db.DAO;
import com.opensymphony.xwork2.ActionSupport;
import com.suypower.carManage.comm.ConstUtil;

import javax.servlet.ServletException;

public class TyreAction extends ActionSupport{

	private String id;
	private String car_code;
	private String change_date;
	private String driver;
	private String price;
	private String remark;
    private String milage;

    public String getMilage() {
        return milage;
    }

    public void setMilage(String milage) {
        this.milage = milage;
    }

    public String execute(){
		String res = "";
		DAO dao = new DAO();
		String sql = "";
		if (id != null && !id.equals("")) {
			sql="UPDATE dbo.tb_tyre SET car_code = '"+car_code+"',milage='"+milage+"', change_date = '"+change_date+"', driver = '"+driver+"', price = '"+price+"', remark = '"+remark+"' where id="+id;
		}else{
			sql="INSERT INTO tb_tyre ( car_code, change_date, driver, price,milage, remark ) VALUES ( '"+car_code+"', '"+change_date+"', '"+driver+"', '"+price+"', '"+milage+"','"+remark+"' )";
		}
		int count = 0;
		try {
			count = dao.execCommand(ConstUtil.DBNAME, sql);
			if (count > 0) {
				res = this.SUCCESS;
			} else {
				res = this.ERROR;
			}
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return res;
	}


	public String getId() {
		return id;
	}


	public void setId(String id) {
		this.id = id;
	}


	public String getCar_code() {
		return car_code;
	}


	public void setCar_code(String carCode) {
		car_code = carCode;
	}


	public String getChange_date() {
		return change_date;
	}


	public void setChange_date(String changeDate) {
		change_date = changeDate;
	}


	public String getDriver() {
		return driver;
	}


	public void setDriver(String driver) {
		this.driver = driver;
	}


	public String getPrice() {
		return price;
	}


	public void setPrice(String price) {
		this.price = price;
	}


	public String getRemark() {
		return remark;
	}


	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	
	
	
}
